﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="MenuInRole.aspx.cs" Inherits="admin_system_MenuInRole" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head" runat="Server">
    <script src="../../Scripts/jQuery1.7.js" type="text/javascript"></script>
    <script src="../../Plugin/flexigrid1.2/js/flexigrid.js" type="text/javascript"></script>
    <link href="../../Plugin/flexigrid1.2/css/flexigrid.pack.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/sjn.1.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        $(function () {

            $("#tb_MenuList").flexigrid({
                height: 'auto',
                width: 'auto',
                checkbox: true,
                onRowClick: function (tr) {
                    if (!$(tr).attr("path")) {
                        return;
                    }
                    var path = $(tr).attr("path").split("|");
                    var id = $(tr).attr("id");
                    if ($("input[type='checkbox']", tr).attr("checked")) {

                        //当前为选中状态时，改变其所有父类都为选中状态
                        $(path).each(function (i, item) {
                            $("#" + item).toggleClass('trSelected', true).find("input[type='checkbox']").attr("checked", true);
                        })
                    } else {

                        //当前为未选中状态时，改变其所有子类为未选中状态
                        $("." + id).each(function (i, item) {
                            $(item).toggleClass('trSelected', false).find("input[type='checkbox']").attr("checked", false);
                        })
                    }
                }
            });


            $.get(
                "/admin/system/menuinrole.aspx?fun=getMenuByRoled&id=" + myurl().attr("id"),
                function (txt) {
                    if (txt != "" && txt != undefined && txt != null) {
                        var ids = txt.split(",");
                        $(ids).each(function (i, item) {
                            $("#tb_MenuList").find("input[name='row_box'][value='" + item + "']").attr("checked", true).change();
                        });
                    }
                }
            )
        });


    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Title" runat="Server">
    系统管理 - <a href="/admin/system/RolesList.aspx">角色管理</a> - 菜单权限
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Control" runat="Server">
    <input type="hidden" id="fun" name="fun" value="submitSave" />
    <input type="submit" value="保存" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Content" runat="Server">
    <table id="tb_MenuList">
        <thead>
            <tr>
                <th width="700" style="text-align: center;">
                    菜单名称
                </th>
            </tr>
        </thead>
        <tbody>
            <asp:Repeater ID="rp_list" runat="server">
                <ItemTemplate>
                    <tr id="<%#Eval("ID")%>" class="<%#Eval("Path").ToString().Replace("|"," ")%>" path ="<%#Eval("Path")%>" >
                        <td>
                            <div style="margin-left: <%#(Convert.ToInt32(Eval("Depth"))-1)*30 %>px;">
                                <%#Eval("Name")%></div>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </tbody>
    </table>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Foot" runat="Server">
</asp:Content>
